package view;

import java.util.Enumeration;
import java.util.Vector;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.GroupLayout;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

import model.Employee;
import model.Reservation;
import control.ReservationControl;

import java.awt.FlowLayout;

import javax.swing.BoxLayout;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;

import javax.swing.LayoutStyle.ComponentPlacement;
import javax.swing.border.LineBorder;

import java.awt.Color;

public class F_Checkin extends JPanel {
	private JTable table_listreservation;

	private Vector rowHeader = new Vector();
	private Vector rowData = new Vector();
	private DefaultTableModel defaultTableModel;

	// --------------------
	private ReservationControl reservationControl;

	/**
	 * Create the panel.
	 */
	public F_Checkin(F_Main f, Employee employee) {
		setSize(f.getWidth(), f.getHeight());
		reservationControl = new ReservationControl();

		String[] columnNames = { "Reservation ID", "Customer", "Room",
				"Date Booking From", "Date Booking From", "Emlpoyee" };
		rowHeader.add("Reservation ID");
		rowHeader.add("Customer");
		rowHeader.add("Room");
		rowHeader.add("Date Booking Form");
		rowHeader.add("Date Booking To");
		rowHeader.add("Emlpoyee");
		rowHeader.add("Emlpoyee");

		defaultTableModel = new DefaultTableModel(rowHeader, 6);
		//
//		Enumeration emp = reservationControl.getlistReservation()
//				.getReservations().elements();
//		while (emp.hasMoreElements()) {
//			Reservation each = (Reservation) emp.nextElement();
//			rowData = new Vector();
//			rowData.add(each.getReservation_id());
//			rowData.add(each.getCustomer_id());
//			rowData.add(each.getRoom_id());
//			rowData.add(each.getExpected_arrive_date());
//			rowData.add(each.getExpected_departure_date());
//			rowData.add(each.getEmployee_reservation());
//			rowData.add(new JButton("Check-in"));
//
//			defaultTableModel.addRow(rowData);
//		}

		// -----------------------------------------
		JPanel panel = new JPanel();
		panel.setBorder(new LineBorder(new Color(0, 0, 0)));
		GridBagLayout gbl_panel = new GridBagLayout();
		gbl_panel.columnWidths = new int[] { 0 };
		gbl_panel.rowHeights = new int[] { 0 };
		gbl_panel.columnWeights = new double[] { Double.MIN_VALUE };
		gbl_panel.rowWeights = new double[] { Double.MIN_VALUE };
		panel.setLayout(gbl_panel);

		JPanel panel_1 = new JPanel();
		panel_1.setSize(this.getWidth(), this.getHeight());
		panel_1.setLayout(new GridLayout(0, 1, 0, 0));
		GroupLayout groupLayout = new GroupLayout(this);
		groupLayout
				.setHorizontalGroup(groupLayout
						.createParallelGroup(Alignment.TRAILING)
						.addGroup(
								groupLayout
										.createSequentialGroup()
										.addGroup(
												groupLayout
														.createParallelGroup(
																Alignment.LEADING)
														.addComponent(
																panel_1,
																GroupLayout.PREFERRED_SIZE,
																542,
																GroupLayout.PREFERRED_SIZE)
														.addComponent(
																panel,
																GroupLayout.PREFERRED_SIZE,
																542,
																GroupLayout.PREFERRED_SIZE))
										.addContainerGap(
												GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)));
		groupLayout.setVerticalGroup(groupLayout.createParallelGroup(
				Alignment.LEADING).addGroup(
				groupLayout
						.createSequentialGroup()
						.addComponent(panel, GroupLayout.PREFERRED_SIZE, 79,
								GroupLayout.PREFERRED_SIZE)
						.addGap(162)
						.addComponent(panel_1, GroupLayout.PREFERRED_SIZE, 150,
								GroupLayout.PREFERRED_SIZE)));

		table_listreservation = new JTable();
		panel_1.add(table_listreservation);
		table_listreservation.setSize(f.getWidth(), f.getHeight());

		table_listreservation.setModel(defaultTableModel);
		table_listreservation.setAutoCreateRowSorter(true);
		setLayout(groupLayout);

	}
}
